package angry.courses.entities;
import javax.persistence.*;

@Entity
@NamedQueries({
	@NamedQuery(name="retrieveCourse",query="SELECT c FROM CourseEntity c WHERE c.name=:name"),
	@NamedQuery(name="retrieveCourseByCid",query="SELECT c FROM CourseEntity c WHERE c.cid=:cid"),
	@NamedQuery(name="retrieveCoursesForSemester",query="SELECT c FROM CourseEntity c WHERE c.semester=:semester"),
	@NamedQuery(name="retrieveCoursesForYearAndSemester",query="SELECT c FROM CourseEntity c WHERE c.year=:year AND c.semester=:semester")
})
@Table(name="courses")
public class CourseEntity implements java.io.Serializable {

	//create table courses(cid int NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(25), year int, semester int, professor varchar(25));

	@Id
	@GeneratedValue
	@Column(name="cid",nullable=false)
	int cid;
	
	@Column(name="name",length=25)
	String name;

	@Column(name="year")
	int year;

	@Column(name="semester")
	int semester;

	@Column(name="professor",length=25)
	String professor;

	public CourseEntity() {}

	public CourseEntity(String name, int year, int sem, String prof) {
		this.name = name;
		this.year = year;
		this.semester = sem;
		this.professor = prof;		
	}

	public String getName() {
		return name;
	}

	public int getYear() {
		return year;
	}

	public int getSemester() {
		return semester;
	}

	public String getProfessor() {
		return professor;
	}	

	public int getID() {
		return cid;
	}
}
